package scsc.pub.process.leave;

import java.util.List;

import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.def.AssignmentHandler;
import org.jbpm.taskmgmt.exe.Assignable;

import scsc.pub.db.DBManage;

public class SwimlaneMng implements AssignmentHandler {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void assign(Assignable assignable, ExecutionContext executionContext)
			throws Exception {
		long swimlaneID=executionContext.getTask().getSwimlane().getId();
		//.getProcessDefinition().getTaskMgmtDefinition().getTask("ChiefApprove").getSwimlane().getId();
		DBManage dbmanage=new DBManage();
		String hql="select slopt.comp_id.operatorId from SwimlaneOperator as slopt where slopt.comp_id.swimlaneId="+swimlaneID;
		List result=dbmanage.sqlQuery(hql);
		dbmanage.close();
		String[] actorId=new String[result.size()];
		for(int i=0;i<result.size();i++)
		{
			actorId[i]=result.get(i).toString();
		}
		assignable.setPooledActors(actorId);

	}

}
